< previous page page_595 next page >

Page 595
e10a6a0a59f035e870d90cca05b85fce.gif
         If G < 0 Then G = 0
         If B < 0 Then B = 0
     End If
End Sub
Subroutine TraceAllRays traces all the rays passing from the center of projection through the pixels in a picture box. This routine takes a parameter skip that indicates how many pixels it should skip in its calculations. For example, if skip is 2, the routine examines every second pixel. It then uses the result it gets to draw a two-by-two area on the picture box, so you can see a low-resolution preview of the final image. If skip is large, this can be much faster than generating the entire image at full resolution. Figure 17.7 shows an image of three spheres in which skip is 8. Figure 17.8 shows the same image with skip set to 1 so that every pixel's value is calculated separately.
e10a6a0a59f035e870d90cca05b85fce.gif
' Ray trace on this picture box.
Public Sub TraceAllRays(ByVal pic As PictureBox, _
    ByVal skip As Integer, ByVal depth As Integer)
Dim pixels() As RGBTriplet
Dim bits_per_pixel As Integer
Dim pix_x As Long
Dim pix_y As Long
Dim real_x As Long
Dim real_y As Long
Dim Xmin As Integer
Dim Xmax As Integer
Dim Ymin As Integer
Dim Ymax As Integer
Dim xoff As Integer
Dim yoff As Integer
Dim R As Integer
Dim G As Integer
Dim B As Integer
Dim obj As RayTraceable
0595-01.jpg
Figure 17.7
A low-resolution preview image.

 
< previous page page_595 next page >